# -*_ codeing=utf-8 -*-
# @Time: 2025/10/29 14:17
# @Author: foxhuty
# @File: schemas.py
# @Software: PyCharm
# @Based on python 3.13
from datetime import date
from decimal import Decimal
from typing import Optional

from pydantic import BaseModel, Field
from sqlalchemy_notes.student_manager.models import SexValue, Department


class EmployeeCreateSchema(BaseModel):
    """创建员工的模型类"""
    id: int = Field(description="Employee ID", default=None)
    name: str = Field()
    gender: SexValue = Field(default=None)
    salary: Decimal = Field(default=None)
    bonus: int = Field(default=None)
    is_leave: bool = Field(default=False)
    entry_date: date = Field(default=None)
    dept_id: Optional[int] = Field(default=None)

    class ConfigDict:
        # 此配置自动把ORM模型对象转投成Pydantic模型对象
        # orm_mode=True
        from_attributes = True


class DepartmentCreateSchema(BaseModel):
    """创建部门类"""
    id: int = Field(description="Department ID", default=None)
    name: str = Field(description="Department name", default=None)
    city: str = Field(description="Department city", default=None)

    class ConfigDict:
        # 此配置自动把ORM模型对象转投成Pydantic模型对象
        # orm_mode=True
        from_attributes = True


class EmpResponse(EmployeeCreateSchema):
    # 响应后的员工信息，包括部门信息
    dept: Optional[DepartmentCreateSchema] = Field(description="Department", default=None)

    class ConfigDict:
        # 此配置自动把ORM模型对象转投成Pydantic模型对象
        # orm_mode=True
        from_attributes = True
